package com.easylinkin.linkappapi.investigation.controller;


import com.easylinkin.linkappapi.investigation.entity.InvestigationTaskDetail;
import com.easylinkin.linkappapi.investigation.service.InvestigationTaskDetailService;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import site.morn.rest.RestBuilders;
import site.morn.rest.RestMessage;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpSession;

/**
 * <p>
 * 排查任务详情 前端控制器
 * </p>
 *
 * @author TongJie
 * @since 2021-04-16
 */
@RestController
@RequestMapping("/investigation/investigationTaskDetail")
public class InvestigationTaskDetailController {

    @Resource
    private InvestigationTaskDetailService service;

    /**
     * 上传图片，调用iP/NB
     */
    @PostMapping("sendFacePicture")
    public RestMessage handle(@RequestBody InvestigationTaskDetail investigationTaskDetail, HttpServletRequest request) {
        HttpSession session = request.getSession(false);
        if (session == null) {
            return RestBuilders.failureBuilder().code("401").message("找不到会话").build();
        }
        return RestBuilders.successBuilder(service.sendFacePicture(investigationTaskDetail.getFacePicture(),session.getId())).build();
    }

}
